-
Notifications
You must be signed in to change notification settings - Fork 14.8k
release/21.x: [libc++] Add checks for misused hardening macros (#150669) #151582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@philnik777 What do you think about merging this PR to the release branch? |
@llvm/pr-subscribers-libcxx Author: None (llvmbot) ChangesBackport 955ece4 Requested by: @ldionne Full diff: https://github.com/llvm/llvm-project/pull/151582.diff 1 Files Affected:
diff --git a/libcxx/include/__config b/libcxx/include/__config
index 7bb5d9ac77ea4..b1660c3f89b01 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -40,9 +40,21 @@
// HARDENING {
-// TODO: Remove in LLVM 21. We're making this an error to catch folks who might not have migrated.
-# ifdef _LIBCPP_ENABLE_ASSERTIONS
-# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE instead"
+// TODO(LLVM 23): Remove this. We're making these an error to catch folks who might not have migrated.
+// Since hardening went through several changes (many of which impacted user-facing macros),
+// we're keeping these checks around for a bit longer than usual. Failure to properly configure
+// hardening results in checks being dropped silently, which is a pretty big deal.
+# if defined(_LIBCPP_ENABLE_ASSERTIONS)
+# error "_LIBCPP_ENABLE_ASSERTIONS has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
+# endif
+# if defined(_LIBCPP_ENABLE_HARDENED_MODE)
+# error "_LIBCPP_ENABLE_HARDENED_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
+# endif
+# if defined(_LIBCPP_ENABLE_SAFE_MODE)
+# error "_LIBCPP_ENABLE_SAFE_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
+# endif
+# if defined(_LIBCPP_ENABLE_DEBUG_MODE)
+# error "_LIBCPP_ENABLE_DEBUG_MODE has been removed, please use _LIBCPP_HARDENING_MODE=<mode> instead (see docs)"
# endif
// The library provides the macro `_LIBCPP_HARDENING_MODE` which can be set to one of the following values:
|
Who can review? btw what's up with the buildkite ci never ending? |
ping |
I don't know; I've pinged the owner. I don't think it should be blocking though. |
Libc++ hardening went through several iterations, sometimes within a single release. However, some folks in the wild have picked up these macros that were either public at some point or that were used temporarily on `main`, and unfortunately those are now ignored. This can lead to some users thinking they enable hardening when in reality they don't, which is a pretty big deal. This patch simply checks various old hardening-related macros and ensures that they are not set, which will catch such misuse. (cherry picked from commit 955ece4)
Backport 955ece4
Requested by: @ldionne